#!/bin/bash
# 猜拳游戏

game=("石头" "剪刀" "布")
num=$[RANDOM%3]
computer=${game[$num]}
#获取随机出拳，保存在数组中

echo "请根据提示，选择您的出拳"
echo "1.石头"
echo "2.剪刀"
echo "3.布"

read -p "请选择[1-3]：" choose

case $choose in
1)
   echo "计算机出：$computer"
   if [ $num -eq 0 ];then
	   echo "平局"
   elif [ $num -eq 1 ];then
	   echo "you win"
   else
	   echo "you lose"
   fi;;
2)
   echo "计算机出：$computer"
   if [ $num -eq 0 ];then
	   echo "you lose"
   elif [ $num -eq 1 ];then
	   echo "平局"
   else
	   echo "you win"
   fi;;
3)
   echo "计算机出：$computer"
   if [ $num -eq 0 ];then
	   echo "you win"
   elif [ $num -eq 1 ];then
	   echo "you lose"
   else
	   echo "平局"
   fi;;
*)
 	echo "必须输入1-3"
esac
